/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package de.aeo.bll;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 * @author Frederic Branczyk & Robert Piwonski
 */
public class Manager {
    
    private ArrayList<Subject> subjectList;
    private ArrayList<Student> studentList;
    private int subjectMinMin = 5;
    private int subjectMinMax = 10;
    private int subjectMaxMin = 11;
    private int subjectMaxMax = 40;
    private Language language;
    private ArrayList<ArrayList<Course>> schedule;
    private ArrayList<Course> overfilled;
//    private Algorithm a;
    
    /**
     * Data layer, contains all data at any time.
     */
    public Manager() {
        this.language = new Language_de();
        this.subjectList = new ArrayList();
        this.studentList = new ArrayList();
        this.schedule = new ArrayList<ArrayList<Course>>();
        this.overfilled = new ArrayList<Course>();
        //this.a = new Algorithm(this);
    }
    
    public void importData(File file) throws MalformedURLException, ImproperDataException, IOException {
        Import import_data = new Import(this.subjectList, this);
        import_data.importData(file);
        this.studentList = import_data.getStudents();
        this.subjectList = import_data.getSubjects();
    }
    
    public void exportData(File file) throws MalformedURLException, FileNotFoundException {
        Export export_data = new Export(this.subjectList, this.studentList, this);
        try {
            export_data.exportData(file);
        } catch (IOException ex) {
            Logger.getLogger(Manager.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    public void exportResultData() throws FileNotFoundException, IOException {
        Export export_data = new Export(this.subjectList, this.studentList, this);
        export_data.deleteDir(new File("data"));
        (new File("data/classes")).mkdirs();
        (new File("data/layers")).mkdirs();
        (new File("data/layers/1")).mkdirs();
        (new File("data/layers/2")).mkdirs();
        (new File("data/layers/3")).mkdirs();
        (new File("data/layers/4")).mkdirs();
        export_data.exportAllClasses();
        export_data.exportAllCourses();
        export_data.exportImpossibleStudents();
    }

    public ArrayList<Student> getStudentList() {
        return studentList;
    }

    public void setStudentList(ArrayList<Student> studentList) {
        this.studentList = studentList;
    }
    
    public void addStudentList(Student s) {
        this.studentList.add(s);
    }

    public ArrayList<Subject> getSubjectList() {
        return subjectList;
    }

    public void setSubjectList(ArrayList<Subject> subjectList) {
        this.subjectList = subjectList;
    }
    
    public void addSubjectList(Subject s) {
        this.subjectList.add(s);
    }

    public int getSubjectMaxMax() {
        return subjectMaxMax;
    }

    public void setSubjectMaxMax(int subjectMaxMax) {
        this.subjectMaxMax = subjectMaxMax;
    }

    public int getSubjectMaxMin() {
        return subjectMaxMin;
    }

    public void setSubjectMaxMin(int subjectMaxMin) {
        this.subjectMaxMin = subjectMaxMin;
    }

    public int getSubjectMinMax() {
        return subjectMinMax;
    }

    public void setSubjectMinMax(int subjectMinMax) {
        this.subjectMinMax = subjectMinMax;
    }

    public int getSubjectMinMin() {
        return subjectMinMin;
    }

    public void setSubjectMinMin(int subjectMinMin) {
        this.subjectMinMin = subjectMinMin;
    }

    public int getSubjectCount() {
        return this.subjectList.size();
    }

    public int getStudentCount() {
        return this.studentList.size();
    }

    public Language getLanguage() {
        return language;
    }

    public void setLanguage(Language language) {
        this.language = language;
    }

    public ArrayList<ArrayList<Course>> getSchedule() {
        return schedule;
    }

    public void setSchedule(ArrayList<ArrayList<Course>> schedule) {
        this.schedule = schedule;
    }

//    public Algorithm getA() {
//        return a;
//    }
//
//    public void setA(Algorithm a) {
//        this.a = a;
//    }
    
    
    

    public ArrayList<Course> getOverfilled() {
        return this.overfilled;
    }

    public void setOverfilled(ArrayList<Course> overfilled) {
        this.overfilled = overfilled;
    }
            
}